﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebUI
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.labMessage.Text = "";
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string message=null; //中文注释了...aaa.f

            if (BLL.UserInfo.Login(this.txtUserName.Text, this.txtPassword.Text, ref message))
            {
                //dxf diffzxdsdf再加
                Session["username"] = this.txtUserName.Text;
                Session["uid"] = message;
                //验证,注册门票,同时跳到 defaulturl
                FormsAuthentication.RedirectFromLoginPage(this.txtUserName.Text, false);
                Response.Redirect("pro/Index.aspx");

                //定义票
                /*FormsAuthenticationTicket ticket =
                    new FormsAuthenticationTicket(this.txtUserName.Text, true, 1);
                //加密票
                string t = FormsAuthentication.Encrypt(ticket);

                //创建 cookies
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, t);

                //创建持久
                cookie.Expires = DateTime.Now.AddMinutes(1);

                Response.Cookies.Add(cookie);

                if (Request["ReturnUrl"] != null)
                {
                    Response.Redirect(Request["ReturnUrl"]);
                }
                else
                {
                    Response.Redirect("pro/Index.aspx");
                }*/
            }
            else {
                this.labMessage.Text = "提示：" + message;
            }
        }
    }
}
